home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / tess / tess-1.0 / p1.m < prev    next >
Encoding:
Text File  |  1992-06-30  |  1.6 KB  |  94 lines

  1. #import "aGroup-inter.h"
  2. #import "p1.h"
  3.  
  4. @implementation p1
  5. - defaultConfig
  6. {
  7.   [self singleAngleSetup: 0.2];
  8.   return self;
  9. }
  10.  
  11. - generator: (NXCoord) x : (NXCoord) y 
  12. {     
  13.   [self clip: x : y];
  14.   PSstroke();
  15.   return self;
  16. }
  17.  
  18. - resizeGenerator
  19. {
  20.   latticesize.height = frame.size.height;
  21.   latticesize.width = frame.size.width;
  22.   upx = [angle1slide floatValue] * latticesize.width;
  23.   printf("Angleslider%f\n",[angle1slide floatValue]);
  24.   upy = latticesize.height;
  25.   overx = latticesize.width - abs(upx);
  26.   gravy = upy/2;
  27.   gravx = (upx+overx)/2;
  28.   return self;
  29. }
  30.  
  31. - clip: (NXCoord) x: (NXCoord) y 
  32.   if(upx < 0.0)
  33.     PSmoveto(x-upx,y);
  34.   else 
  35.     PSmoveto(x,y);
  36.   PSrlineto(overx,0);
  37.   PSrlineto(upx,upy);
  38.   PSrlineto(-overx,0);
  39.   PSclosepath();
  40.   PSclip();
  41.   return self;
  42. }
  43.  
  44. - makeLatticeUnitAt: (NXPoint *) point fromImage: srcimg 
  45. {
  46.   id imgrep;
  47.   NXPoint pt;
  48.   
  49.   pt.x = - point->x ;
  50.   pt.y = - point->y ;
  51.   imgrep = [srcimg bestRepresentation];
  52.   PSgsave();
  53.   PStranslate(-gravx,-gravy);
  54.   [self clip:0.0:0.0];
  55.   [imgrep drawAt: &pt];
  56.   PSgrestore();
  57.   return self;
  58. }
  59.  
  60. - rightTranslatePoint: (NXPoint *) pt
  61. {
  62.   pt->x += overx;
  63.   pt->y += 0;
  64.   return self;
  65. }
  66. - leftTranslatePoint: (NXPoint *) pt
  67. {
  68.   pt->x -= overx;
  69.   pt->y += 0;
  70.   return self;
  71. }
  72.  
  73. - isRigidLattice { return NO; }
  74.  
  75. - upTranslatePoint: (NXPoint *)pt
  76. {
  77.   pt->x += upx;
  78.   pt->y += upy;
  79.   return self;
  80. }
  81.  
  82. - singleAngleSetup: (float) a
  83. {
  84.   [super singleAngleSetup: a];
  85.   [angle1slide setMaxValue: 0.9];
  86.   [angle1slide setMinValue: -0.9];
  87.   [angle1slide setAction: @selector(anglesDidChange)];
  88.   [angle1slide setTarget: self];
  89.   return self;
  90. }
  91.  
  92. @end
  93.